package com.why.constantpool;

import com.why.basictype.U1;
import com.why.basictype.U2;

import java.io.InputStream;

/**
 * @author by xiaoTian
 * @date 2022/5/21.
 */
public class ConstantMethodHandleInfo extends ConstantPoolInfo{

    private byte referenceKind;
    private short referenceIndex;

    public ConstantMethodHandleInfo(byte tag){
        setTag(tag);
    }

    @Override
    public void read(InputStream inputStream) {
        U1 referenceKindU = U1.read(inputStream);
        U2 referenceIndexU = U2.read(inputStream);

        this.referenceKind = referenceKindU.getValue();
        this.referenceIndex = referenceIndexU.getValue();

    }

    @Override
    public String toString() {
        return "ConstantMethodHandleInfo{" +
                "referenceKind=" + referenceKind +
                ", referenceIndex=" + referenceIndex +
                '}';
    }
}
